package com.coincalf.task.task;

import com.coincalf.feign.AccountServiceClient;
import com.coincalf.framework.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Description: 充币到账任务
 * @Author: Chen Long
 * @Date: Created in 2018/5/21 下午5:11
 * @Modified by: Chen Long
 */
@Slf4j
@Component
@EnableScheduling
public class CoinRechargeTask {

    @Autowired
    private AccountServiceClient accountServiceClient;

    /**
     * 充币到账任务，每30秒执行一次
     */
    @Scheduled(fixedRate = 3000)
    public void trigger() {
        log.info("开始执行充币到账任务 当前时间={}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
        accountServiceClient.recharge();
    }

}
